#include "TransformData.h"
#include "TransformComponent.h"
const AssetType TransformData::m_TransformDataType = "TransformData";
bool TransformData::Restore()
{
	return true;
}
bool TransformData::Release()
{
	return true;
}

ActorComponentPtr TransformData::CreateComponent(ActorPtr Owner)
{
	ActorComponentPtr cmp(RE_NEW TransformComponent);

	TransformComponent* trans = dynamic_cast<TransformComponent*>(cmp.get());
	
	//build the matrix to default state
	D3DXMATRIX temp;
	D3DXMatrixRotationYawPitchRoll(&temp, Rotation.y, Rotation.x, Rotation.z);
	D3DXMatrixTranslation(&trans->m_ToWorld, Position.x, Position.y, Position.z);
	trans->m_ToWorld = temp * trans->m_ToWorld;
	trans->m_ToWorld._14 = Scale.x;
	trans->m_ToWorld._24 = Scale.y;
	trans->m_ToWorld._34 = Scale.z;
	trans->m_pOwner = Owner.get();
	return cmp;
}